import Vue from 'vue';
import App from './App.vue';
import router from './router';
import iView from 'iview';
import i18n from './base/i18n';
import store from './store';

// 判断浏览器的语言
const navLang = navigator.language;
const localLang = (navLang === 'zh-CN' || navLang === 'en-US') ? navLang : false;

let curLang = null;
const pubStr = localStorage.getItem('_analytics_public');
if (pubStr !== null) {
  const tmpObj = JSON.parse(pubStr) || {};
  curLang = tmpObj.lang;
}

i18n.locale = curLang || localLang || 'zh-CN';

Vue.config.productionTip = false;
Vue.use(iView, {
  i18n: (key, value) => i18n.t(key, value)
});

new Vue({
  i18n,
  router,
  store,
  render: h => h(App)
}).$mount('#app');
